import request from '@/utils/request'

export function login (username: string, password: string) {
  return request({
    url: '/login',
    method: 'post',
    data: {
      username: username,
      password: password
    }
  })
}

export function groupList () {
  return request({
    url: '/questionGroup/list',
    method: 'get'
  })
}

export function questionList (groupId: number) {
  return request({
    url: '/question/group/' + groupId,
    method: 'get'
  })
}

export function editQuestion (form: any) {
  return request({
    url: '/question/edit',
    method: 'post',
    data: form
  })
}

export function deleteQuestion (questionId: number) {
  return request({
    url: '/question/delete/' + questionId,
    method: 'delete'
  })
}

export function deleteGroup (groupId: number) {
  return request({
    url: '/questionGroup/delete/' + groupId,
    method: 'delete'
  })
}

export function typeList () {
  return request({
    url: '/questionType/list',
    method: 'get'
  })
}

export function addGroup (groupName: string, questionTypeId: any, remark: string) {
  return request({
    url: '/questionGroup/add',
    method: 'post',
    data: {
      groupName: groupName,
      questionTypeId: questionTypeId,
      remark: remark
    }
  })
}

export function editGroup (form: any) {
  return request({
    url: '/questionGroup/edit',
    method: 'post',
    data: form
  })
}

export function addQuestion (form: any) {
  return request({
    url: '/question/add',
    method: 'post',
    data: form
  })
}

export function codeSize (qq: string) {
  return request({
    url: '/code/pageSize',
    method: 'get',
    params: {
      qq: qq
    }
  })
}

export function codeList (page: number, qq: string) {
  return request({
    url: '/code/list',
    method: 'get',
    params: {
      page: page,
      qq: qq,
      limit: 9
    }
  })
}

export function editCode (form: any) {
  return request({
    url: '/code/edit',
    method: 'post',
    data: form
  })
}

export function addCode (qq: string) {
  return request({
    url: '/code/create',
    method: 'post',
    data: {
      qq: qq
    }
  })
}

export function deleteCode (codeId: number) {
  return request({
    url: '/code/delete/' + codeId,
    method: 'delete'
  })
}

export function testList (page: number, qq: string) {
  return request({
    url: '/test/list',
    method: 'get',
    params: {
      page: page,
      qq: qq,
      limit: 9
    }
  })
}

export function testSize (qq: string) {
  return request({
    url: '/test/pageSize',
    method: 'get',
    params: {
      qq: qq
    }
  })
}

export function deleteTest (testId: number) {
  return request({
    url: '/test/delete/' + testId,
    method: 'delete'
  })
}

export function viewTest (testId: number) {
  return request({
    url: '/test/view/' + testId,
    method: 'get'
  })
}

export function updateRule (form: any) {
  return request({
    url: '/questionType/rule',
    method: 'post',
    data: {
      rules: form
    }
  })
}
